package com.chixing.ih.module.system.service.Impl;

import com.chixing.ih.module.system.mapper.AdminMapper;
import com.chixing.ih.module.system.pojo.Admin;
import com.chixing.ih.module.system.service.IAdminService;
import com.chixing.ih.util.EncryptUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘岩
 * Date: 2020-09-26
 * Time: 13:42
 *
 * @version 1.0
 */
@Service
@Transactional
public class AdminServiceImpl implements IAdminService {

    @Autowired
    AdminMapper adminMapper;

    @Override
    public boolean isAccountExisted(String adminAccount) {
        Admin adminByAccount = adminMapper.getAdminByAccount(adminAccount);
        if (adminByAccount == null) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public Admin isLoginSuccess(Admin admin) {
        admin.setAdminPassword(EncryptUtil.encrypt(admin.getAdminPassword(), null));
        return adminMapper.getAdmin(admin);
    }
}
